% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/calc_ratios_to_avg.R
\name{calc_ratios_to_avg}
\alias{calc_ratios_to_avg}
\title{get ratios of each site's scores to US means (using output of batch buffering)}
\usage{
calc_ratios_to_avg(
  out,
  evarnames = names_e,
  dvarnames = c(names_d, names_d_subgroups),
  zone.prefix = c("", "state.")[1],
  avg.evarnames = paste0(zone.prefix, "avg.", evarnames),
  avg.dvarnames = paste0(zone.prefix, "avg.", dvarnames)
)
}
\arguments{
\item{out}{data.frame output from \code{\link[=ejscreenapi_plus]{ejscreenapi_plus()}} or from \code{\link[=ejscreenapi]{ejscreenapi()}} or doaggregate(),
one row per buffer or site, and
columns for indicators named in evarnames, dvarnames, avg.evarnames, avg.dvarnames}

\item{evarnames}{vector of variable names for environmental indicators in out, like pm, o3, etc.}

\item{dvarnames}{vector of variable names for demographic indicators in out, such as pctlowinc}

\item{zone.prefix}{us or state, must fit with colnames in out such as  avg.pctlowinc and state.avg.pctlowinc}

\item{avg.evarnames}{use only if user-specific variable names are in out,
with defaults like avg.pm}

\item{avg.dvarnames}{use only if user-specific variable names are in out,
with defaults like  avg.pctlowinc}
}
\value{
a list with ratios_d and ratios_e which are
vectors of numbers the lengths of dvarnames and evarnames
}
\description{
Used to create input to\code{\link[= boxplots_ratios]{ boxplots_ratios()}} and can be used elsewhere now
}
\details{
Note that colnames returned are same as input, not renamed to say "ratio"
If names_d_subgroups are included, those means are not in API output from EJScreen
so it gets the means from usastats or statestats
}
\examples{
 out <- testoutput_ejscreenit_5$table # has long names
 names(out) <- fixcolnames(names(out1),'long','r')
 out2 <- testoutput_ejscreenapi_plus_5 # has r names already
 
 # these are data.frames, but the colnames are different:
 #   names like "Demog.Index" but they are ratios
 calc_ratios_to_avg(out)$ratios_d
 #   names like "ratio.to.avg.Demog.Index"
 out[ , names_d_ratio_to_avg] # needs EJAM for names_d_ratio_to_avg
 
 boxplots_ratios(calc_ratios_to_avg(out)$ratios_d,"pctlowinc","\% low income", 
     wheretext="Within a mile of")
  
}
\keyword{internal}
